import 'package:flutter/material.dart';

import '../routes.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool showPassword = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('登录'),
        ),
        body: SafeArea(
            minimum: const EdgeInsets.all(28),
            child: Column(
              children: [
                const TextField(
                  decoration:
                      InputDecoration(labelText: '用户名', hintText: '请输入用户名'),
                ),
                const Padding(padding: EdgeInsets.all(10)),
                TextField(
                    obscureText: !showPassword,
                    decoration: InputDecoration(
                        labelText: '密码',
                        hintText: '请输入密码',
                        suffixIcon: IconButton(
                            onPressed: () {
                              setState(() {
                                showPassword = !showPassword;
                              });
                            },
                            icon: Icon(showPassword
                                ? Icons.visibility
                                : Icons.visibility_off)))),
                const Padding(padding: EdgeInsets.all(10)),
                SizedBox(
                  width: double.maxFinite,
                  child: TextButton(
                    style: const ButtonStyle(
                        backgroundColor:
                            MaterialStatePropertyAll(Colors.green)),
                    onPressed: () {
                      //
                    },
                    child: const Text(
                      '登录',
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                ),
                const Padding(padding: EdgeInsets.all(10)),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text('还没有帐户，'),
                    TextButton(
                        onPressed: () {
                          //
                          Navigator.pushReplacementNamed(
                              context, Routes.register);
                        },
                        child: const Text('去注册~'))
                  ],
                )
              ],
            )));
  }
}
